#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const int N = 100005;
const double eps = 1e-9;
int n, m, V, L, d[N], v[N], a[N], q[N]; long double p[N];
struct Seg { int l, r; } s[N], sg[N]; int stot = 0, sgtot = 0;
bool cmp(Seg a, Seg b) { return a.r < b.r; }
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T; scanf("%d", &T);
    while (T--) {
        scanf("%d%d%d%d", &n, &m, &L, &V);
        for (int i = 1; i <= n; i++) scanf("%d%d%d", &d[i], &v[i], &a[i]);
        for (int i = 1; i <= m; i++) scanf("%d", &q[i]), p[i] = q[i];
        sort(p + 1, p + m + 1);
        stot = 0, sgtot = 0;
        for (int i = 1; i <= n; i++) {
            long double tim, len, st, ed;
            if (a[i] < 0) {
                if (v[i] <= V) {
                    continue;
                } else {
                    tim = max((long double)0.0, (long double)(V - v[i]) * 1.0 / a[i]);
                    len = v[i] * tim + 0.5 * a[i] * tim * tim;
                    st = d[i], ed = d[i] + len;
                    // st <= pod < ed;
                    stot++;
                    s[stot] = (Seg) {
                        (int)(lower_bound(p + 1, p + m + 1, st - eps) - p),
                        (int)(lower_bound(p + 1, p + m + 1, ed) - p - 1)
                    };
                }
            } else if (a[i] == 0) {
                if (v[i] <= V) continue;
                else {
                    long double st = d[i], ed = L;
                    // st <= pos <= ed;
                    stot++;
                    s[stot] = (Seg) {
                        (int)(lower_bound(p + 1, p + m + 1, st - eps) - p),
                        (int)(upper_bound(p + 1, p + m + 1, ed + eps) - p - 1)
                    };
                }
            } else {
                tim = max((long double)0.0, (long double)(V - v[i]) * 1.0 / a[i]);
                len = v[i] * tim + 0.5 * a[i] * tim * tim;
                if (len + d[i] > L) continue;
                else st = d[i] + len, ed = L;
                if (v[i] > V) st -= eps;
                // st < pos <= ed
                stot++;
                s[stot] = (Seg) {
                    (int)(upper_bound(p + 1, p + m + 1, st) - p),
                    (int)(upper_bound(p + 1, p + m + 1, ed + eps) - p - 1)
                };
            }
        }
        for (int i = 1; i <= stot; i++)
            if (s[i].l <= s[i].r) sg[++sgtot] = {s[i].l, s[i].r};
        sort(sg + 1, sg + sgtot + 1, cmp);
        int cnt = 0, lst = -1;
        for (int i = 1; i <= sgtot; i++)
            if (sg[i].l > lst) lst = sg[i].r, cnt++;
        printf("%d %d\n", sgtot, m - cnt);
    }
    return 0;
}